package com.moviemetagetter.ui;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import com.moviemetagetter.ui.list.FileList;
import com.moviemetagetter.ui.text.TextField;

public class FileListPanel extends JPanel{

	private JButton refreshButton;
	private TextField pathText;
	private FileList fileList;
	
	public FileListPanel(){
		setLayout(new BorderLayout());
		
		JPanel topPanel = new JPanel();
		
		topPanel.setLayout(new BorderLayout());

		pathText = new TextField("Enter path here");
		
		refreshButton = new JButton();
		refreshButton.setText("Refresh List");
		refreshButton.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				fileList.loadFileList(pathText.getText());
			}
		});
		
		topPanel.add(pathText,BorderLayout.CENTER);
		topPanel.add(refreshButton,BorderLayout.EAST);
		
		fileList = new FileList();
		JScrollPane scrollPane = new JScrollPane(fileList);		
		
		add(topPanel,BorderLayout.NORTH);
		add(scrollPane,BorderLayout.CENTER);
	}
}
